package com.huaxinkaiye.activity;

import com.huaxinkaiye.R;
import com.huaxinkaiye.adapter.NoticeAdapter;
import com.huaxinkaiye.utils.ProgressUtil;
import com.huaxinkaiye.widget.SimpleFooter;
import com.huaxinkaiye.widget.SimpleHeader;
import com.huaxinkaiye.widget.ZrcListView;
import com.huaxinkaiye.widget.ZrcListView.OnStartListener;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class FristPageActivity extends Activity implements OnClickListener, com.huaxinkaiye.widget.ZrcListView.OnItemClickListener{
public ProgressUtil progress;
private ZrcListView listView;
private  NoticeAdapter noticeadapter;
private ImageView im_logo;
private TextView uesr_name;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_frist);
		progress=new ProgressUtil(this, "正在加载");
		initView();
	}

	private void initView() {
		// TODO Auto-generated method stub
		
		im_logo=(ImageView)findViewById(R.id.im_logo);
		im_logo.setOnClickListener(this);
		uesr_name=(TextView)findViewById(R.id.uesr_name);
		
		listView=(ZrcListView)findViewById(R.id.zListView);
	// 设置下拉刷新的样式（可选，但如果没有Header则无法下拉刷新）
        SimpleHeader header = new SimpleHeader(this);
        header.setTextColor(0xff0066aa);
        header.setCircleColor(0xff33bbee);
        listView.setHeadable(header);

        // 设置加载更多的样式（可选）
        SimpleFooter footer = new SimpleFooter(this);
        footer.setCircleColor(0xff33bbee);
        listView.setFootable(footer);
		
        // 设置列表项出现动画（可选）
        listView.setItemAnimForTopIn(R.anim.zrclistview_topitem_in);
        listView.setItemAnimForBottomIn(R.anim.zrclistview_bottomitem_in);
        
        // 下拉刷新事件回调（可选）
        listView.setOnRefreshStartListener(new OnStartListener() {
            @Override
            public void onStart() {
                refresh();
            }
        });

        // 加载更多事件回调（可选）
        listView.setOnLoadMoreStartListener(new OnStartListener() {
            @Override
            public void onStart() {
                loadMore();
            }
        });
        
		noticeadapter=new NoticeAdapter(this);
		listView.setAdapter(noticeadapter);
		listView.setRefreshSuccess("success");
		listView.refresh(); // 主动下拉刷新
		
		listView.setOnItemClickListener(this);
		
	}

	protected void loadMore() {
		// TODO Auto-generated method stub
		
	}

	protected void refresh() {
		// TODO Auto-generated method stub
		listView.setRefreshSuccess("success"); 
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.im_logo:
			 Intent intent=new Intent(this,MainActivity.class); 
			 startActivity(intent);
			 finish();
			break;
		}
		
	}

	@Override
	public void onItemClick(ZrcListView parent, View view, int position, long id) {
		// TODO Auto-generated method stub
		
	}

}
